-
Notifications
You must be signed in to change notification settings - Fork 321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix code quality issues in sof tools #8216
Conversation
32c1256
to
ae1c220
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @softwarecki , looks good to go!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could not find anything else wrong but this commit message appears to be somehow truncated:
logger: convert: Fixed handling of an error reported by clock_gettime
The clock_gettime function only returns information that an error occurred.
The error code should be taken from the e
Signed-off-by: Adrian Warecki [email protected]
Please submit this to stable-v2.2 for actual testing |
fprintf(out_fd, time_fmt, " TIMESTAMP", "DELTA"); | ||
const unsigned int ts_width = timestamp_width(global_config->time_precision); | ||
|
||
fprintf(out_fd, "%*s(us)%*s ", -ts_width, " TIMESTAMP", ts_width, "DELTA"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not equivalent at all. We already discussed this:
This PR has clearly not been tested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In fact, it was done wrong in the linked PR. Run the code below and you will see that both approaches print the same result:
char time_fmt[255];
const unsigned int ts_width = 20;
snprintf(time_fmt, sizeof(time_fmt), "%%-%ds(us)%%%ds ", ts_width, ts_width);
printf(time_fmt, " TIMESTAMP", "DELTA");
printf("\n");
printf("%*s(us)%*s ", -ts_width, " TIMESTAMP", ts_width, "DELTA");
printf("\n");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sincere apologies, I had been "burned" by #6738 and this comment was rushed. I didn't know about %*s
and it looks great.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem, that's what I thought you did it automatically. We discover new things all our lives :)
BTW smex is not part of the binary release, has never been. It's only part of the build process. The incoming 2023.9, Intel's sof-bin release will include the sof-logger from... the 2.2 branch. So sof-logger fixes in the main branch will not affect the release. "Security theater" |
src/audio/module_adapter/iadk/module_initial_settings_concrete.cpp
Outdated
Show resolved
Hide resolved
The values assigned when declaring variables were overwritten in the code. Redundant initialization was removed. Signed-off-by: Adrian Warecki <[email protected]>
ae1c220
to
636bd70
Compare
Absolutely. However code quality implies running the code changes at least once in at least the default configuration.
I'm totally on board with making code simpler not just for humans but also for analyzers - even when it's already correct. Both usually go together and code "very subtly correct" is likely to be broken later. However there will always be some tricky corner cases and all analyzers offer a process to dispose false positives. Dynamically constructing a format string is likely one of these corner cases. |
Backport of 7/10 test and submission to stable-v2.2 where we have more coverage in Intel CI for these tools #8231 |
Thanks all, the tests with backported 2.2 look good ( #8234 ). So only thing missing is a clean run of the mandatory CI. @softwarecki , can you push a rebase and/or ping CI folks to rerun -- the fail is very unlikely to be related to be caused by this PR, but we still need a clean run. |
636bd70
to
fced92e
Compare
smex/elf.c
Outdated
ret = fread(*dst_buff, 1, section->size, module->fd); | ||
if (ret != section->size) { | ||
fprintf(stderr, "error: can't read %s section %d\n", section_name, -errno); | ||
ret = -ENODATA; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd do something like ret = ret < 0 ? -errno : -ENODATA;
but at least this doesn't miss errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it. I fixed returned error codes in another places.
Added checking of the value returned by fseek function and added memory release when an error is detected. Signed-off-by: Adrian Warecki <[email protected]>
035dfdf
to
6849ceb
Compare
If fseek reports an error, the error code set in errno is returned. Improved handling an error during reading from a file. Now it distinguishes between an error reported by the fread and insufficient data in a file. Signed-off-by: Adrian Warecki <[email protected]>
String terminator was added to the buffer with a list of section names in the elf file. Added check to the section name index to make sure it doesn't go beyond the buffer size. Signed-off-by: Adrian Warecki <[email protected]>
The clock_gettime function only returns information that an error occurred. The error code should be taken from the errno variable. Signed-off-by: Adrian Warecki <[email protected]>
6849ceb
to
11dbe92
Compare
@softwarecki can you check CI results. Thanks |
Added checking of value returned by file operation functions. In case of an error, message is printed and error code is returned. Signed-off-by: Adrian Warecki <[email protected]>
The timestamp printing process has been simplified by eliminating the dynamic creation of the formatting string. All necessary parameters are now passed directly to the printing function. Signed-off-by: Adrian Warecki <[email protected]>
…inated Added a null string terminator to be sure that strings read from a file are terminated correctly. Signed-off-by: Adrian Warecki <[email protected]>
The precision check condition has been simplified, the unsigned value cannot be negative. Added definitions containing an error message instead of using a constant variable. Signed-off-by: Adrian Warecki <[email protected]>
Used string manipulation functions that check the size of the available buffer. Signed-off-by: Adrian Warecki <[email protected]>
11dbe92
to
68488ca
Compare
I fixed one checkpatch issue. Its look like we have some problem with CI for windows platform... |
Yep, I'm surprised I'm not hearing any Windows developer complain here unless the Windows build config locally has Ninja and is out of sync with the container ? |
It looks like an intermittent Github glitch, see above. Try re-running that one. |
Filed new |
@softwarecki We need mandatory CIs to pass, this may need a repush (or manually trigger at quickbuild). |
Improved release of resources when an error is detected. Signed-off-by: Adrian Warecki <[email protected]>
68488ca
to
3874d9d
Compare
@kv2019i CI is all green now :) (except checkpatch which complains about camel case in Elf32_Shdr) |
@softwarecki can you check internal CI. I think we are good once it's green. |
Fixed many minor bugs in sof tools applications.